$(document).on 'turbolinks:load', ->
  $('.fileupload').fileupload
    method: 'post'
    url: '/photos'
    formData:
      f: 'jqueryfileupload'
    done: (e, result) ->
      console.log JSON.stringify(result.result)
      image_url = result.result.files[0].url
      $(this).siblings('.preview').html '<img src="' + image_url + '" width="200px" height="200px" />'
      $(this).data 'value', image_url
      console.log $(this).data('value')
